package com.mall.controller;


import com.mall.common.pojo.JsonResult;
import com.mall.common.pojo.PageObject;
import com.mall.pojo.Role;
import com.mall.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @RequestMapping("/doFindPageObjects")
    public JsonResult doFindPageObjects(String name,Integer pageCurrent){
        PageObject<Role> list = roleService.findPageObjects(name, pageCurrent);
        return new JsonResult(list);
    }

    @RequestMapping("/doDeleteObject")
    public JsonResult doDeleteObject(Integer id){
        roleService.deleteObject(id);
        return new JsonResult("删除成功！");
    }


    @RequestMapping("doSaveObject")
    public JsonResult doSaveObject(Role entity,Integer[] menuIds){
        roleService.saveObject(entity, menuIds);
        return new JsonResult("添加成功！");
    }

    @RequestMapping("doFindObjectById")
    public JsonResult doFindObjectById(Integer id){
        return new JsonResult(roleService.findObjectById(id));
    }

    @RequestMapping("doUpdateObject")
    public JsonResult doUpdateObject(Role entity,Integer[] menuIds){
        roleService.updateObject(entity,menuIds);
        return new JsonResult("更新成功！");
    }


}
